package com.share.service.site.navigation.impl;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.share.bean.site.SiteNavi;
import com.share.dao.site.navigation.SiteNaviDao;
import com.share.service.site.navigation.SiteNaviManager;


@Service("siteNaviManager")
public class SiteNaviManagerImpl implements SiteNaviManager {

	@Resource
	private SiteNaviDao snd ;
	
	@Override
	public int deleteSiteNaviManager(Object[] ids) throws Exception {
		int ret = 0 ;
		try {
			this.snd.deleteSiteNaviDao(ids) ;
			ret = 1 ;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret ;
	}

	@Override
	public List<SiteNavi> queryAllSiteNaviManager() throws Exception {
		String hql = "select o from SiteNavi o" ;
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>() ;
		orderby.put("id", "asc") ;
		return this.snd.queryAllSiteNaviDao(hql, orderby) ;
	}

	@Override
	public SiteNavi queryByIdSiteNaviManager(int id) throws Exception {
		
		return this.snd.queryByIdSiteNaviDao(id) ;
	}

	@Override
	public int saveSiteNaviManager(SiteNavi sn) throws Exception {
		int ret = 0 ;
		try {
			sn.setAddDate(new Date()) ;
			this.snd.saveSiteNaviDao(sn) ;
			ret = 1 ;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret ;
	}

	public void setSnd(SiteNaviDao snd) {
		this.snd = snd;
	}

	@Override
	public int updateSiteNaviManager(SiteNavi sn) throws Exception {
		int ret = 0 ;
		try {
			sn.setAddDate(new Date()) ;
			this.snd.updateSiteNaviDao(sn) ;
			ret = 1 ;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret ;
	}

}
